package com.source.hotelbath.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.widget.Toast;

import com.ffcs.network.connect.okhttp.request.PostFormBuilder;

import java.io.File;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 获取图片的tint drawable
 * Created by ZhouMeng on 2017/6/8.
 */

public class TintDrawable {

    public static Drawable tintGetDrawable(Context context, int drawableId, int colorId){
        Drawable icon = context.getResources().getDrawable(drawableId);
        Drawable tintIcon = DrawableCompat.wrap(icon);
        DrawableCompat.setTintList(tintIcon, context.getResources().getColorStateList(colorId));
        return tintIcon;
    }
    public static Bitmap drawableToBitmap(Drawable drawable) {



        Bitmap bitmap = Bitmap.createBitmap(

                drawable.getIntrinsicWidth(),

                drawable.getIntrinsicHeight(),

                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888

                        : Bitmap.Config.RGB_565);

        Canvas canvas = new Canvas(bitmap);

        //canvas.setBitmap(bitmap);

        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());

        drawable.draw(canvas);

        return bitmap;

    }
    public static BigDecimal mul(BigDecimal v1,String v2){
//        BigDecimal b1 = new BigDecimal(Double.toString(v1));
        BigDecimal b2 = new BigDecimal(v2);
        return v1.multiply(b2);
    }

    public static BigDecimal add(BigDecimal v1,BigDecimal v2){

        return v1.add(v2);
    }

    public static BigDecimal sub(BigDecimal v1,BigDecimal v2){

        return v1.subtract(v2);
    }
}
